﻿using System.ComponentModel.Composition;
using MediaAssistant.Controls.WaitScreen;
using MediaAssistant.DAL;
using MefBasic.Helper;

namespace MediaAssistant.Management
{
    

    [Export]
    [Export(typeof(IWaitScreenService))]
    public class WaitScreenService : IWaitScreenService
    {
        [Import]
        private WaitScreenPresenter WaitScreenPresenter { get; set; }
        public void Show()
        {
            SynchronizationContextHelper.Instance.SendInBackground(d => WaitScreenPresenter.Show(), null);
        }
        public void Show(string message)
        {
            SynchronizationContextHelper.Instance.SendInBackground(d => WaitScreenPresenter.Show((string)d), message);
        }
        public void Show(int max, int value)
        {
            SynchronizationContextHelper.Instance.SendInBackground(d => WaitScreenPresenter.Show(0, max, value), null);
        }
        public void Show(int value)
        {
            SynchronizationContextHelper.Instance.SendInBackground(d => WaitScreenPresenter.Show(value), null);
        }

        public void Hide()
        {
            SynchronizationContextHelper.Instance.SendInBackground(d => WaitScreenPresenter.Hide(), null);
        }

        public void AdvanceProgress()
        {
            SynchronizationContextHelper.Instance.SendInBackground(AdvanceProgressAction, null);
        }

        public void Show(int minValue, int maxValue, int currentValue)
        {
            throw new System.NotImplementedException();
        }

        private void AdvanceProgressAction(object obj)
        {
            WaitScreenPresenter.Show(0, WaitScreenPresenter.Maximum, WaitScreenPresenter.Value+1);
        }
    }
}
